package com.example.ch12.document;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * @ClassName Users
 * @Description 文档映射，映射 Users 索引中的属性
 * @Author Kx
 * @Date 2025/10/21 9:11
 * @Version 1.0
 */

/**
 * 使用 @Document 注解，indexName属性指定索引名称，createIndex属性指定是否自动创建索引
 */
@Document(indexName = "users", createIndex = false)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Users {
    @Id
    private String id;
    @Field(type = FieldType.Keyword, index = false)
    private String name;
    @Field(type = FieldType.Integer, index = false)
    private Integer age;
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String birthplace;
}
